package cn.melonlib.specials.auth.model.entity;

import cn.melonlib.cores.commons.model.anno.MelonEntityId;
import cn.melonlib.cores.commons.model.entity.StringIdEntity;
import cn.melonlib.cores.commons.model.entity.TenantRecordEntity;
import cn.melonlib.cores.commons.model.enums.IdType;
import cn.melonlib.cores.commons.model.enums.IdValueType;
import cn.melonlib.cores.commons.model.support.number_id.MelonLibLongIdEntity;
import cn.melonlib.cores.model.anno.ModelComment;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

import javax.persistence.*;

@Data
@EqualsAndHashCode(callSuper = true)
@ModelComment("密码设置记录")
@Entity(name = "AccountPasswordRecord")
@Table(name = "user_account_password_record",schema = "ustudy_admin")
@MelonEntityId(type = IdType.SNOW_FLAKE,IdValueType = IdValueType.LONG)
public class AccountPasswordRecord extends StringIdEntity {
    @ManyToOne(cascade = CascadeType.REFRESH,fetch = FetchType.LAZY)
    @JoinColumn(name = "account_id")
    @ModelComment("账户")
    private Account account;

    @Column
    @Lob@Basic(fetch = FetchType.LAZY)
    @ModelComment("密码，经过AES加密")
    @Type(type = "org.hibernate.type.TextType")
    private String password;

    @ModelComment("密码设置时间")
    private Long initDateTime=System.currentTimeMillis();

    @ModelComment("密码废弃时间")
    private Long scrapDateTime;

    @ModelComment("密码是否废弃")
    private Boolean scrap=false;
}
